﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Web.UI;
//using System.Web.UI.WebControls;

//public partial class Admins_Default1 : System.Web.UI.Page
//{
//    protected void Page_Load(object sender, EventArgs e)
//    {

//    }
//}

//----------------------------------------------------赵洪科-----------------------------------------------//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

//using System.Windows.Forms;



public partial class Admins_Default1 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!IsPostBack)
        //{
        //    OrderList orderlists = new OrderList();
        //    GridView1.DataSource = orderlists.returnOrderList1();
        //    GridView1.DataBind();
        //}
    }
    protected void LinkButton1_Click(object sender, EventArgs e)   //显示全部订单
    {
        OrderList orderlists = new OrderList();
        GridView1.DataSource = orderlists.returnOrderList1();
        GridView1.DataBind();
        //Form1_Paint();
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    //protected void LinkButton3_Click(object sender, EventArgs e)         //按会员ID查找
    //{
    //    OrderList orderlists = new OrderList();
    //    GridView1.DataSource = orderlists.returnOrderList(Convert.ToInt32(TextBox2.Text));
    //    GridView1.DataBind();
    //}
    protected void LinkButton4_Click(object sender, EventArgs e)        //按会员姓名查找
    {
        OrderList orderlists = new OrderList();
        GridView1.DataSource = orderlists.returnOrderList1(TextBox3.Text);
        GridView1.DataBind();
    }
    protected void LinkButton2_Click(object sender, EventArgs e)    //删除订单项
    {
        OrderList orderlist = new OrderList();
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
            if (cb.Checked)
            {
                int str;
                str = Convert.ToInt32(GridView1.Rows[i].Cells[0].Text);  //获取此项ID

                orderlist.removeFr(str);    //删除对应项
            }
        }
        GridView1.DataSource = orderlist.returnOrderList1();
        GridView1.DataBind();
    }

    protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
    {

    }
    /// 在单击 GridView 控件内某一行的 Edit 按钮（其 CommandName 属性设置为“Edit”的按钮）时发生，但在 GridView 控件进入编辑模式之前。此事件通常用于取消编辑操作。
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        OrderList orderlists = new OrderList();
        GridView1.DataSource = orderlists.returnOrderList1();
        GridView1.DataBind();
    }

    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {


        OrderList orderlist = new OrderList();

        DropDownList ddl = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("DDLnScore");
        TextBox tb = (TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1");
        if (tb.Text != " ")
        {

            int id = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[0].Text);
            int id2 = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[1].Text);  //会员ID
            string name = GridView1.Rows[e.RowIndex].Cells[2].Text;    //会员姓名
            string adress = GridView1.Rows[e.RowIndex].Cells[4].Text;
            string phone = GridView1.Rows[e.RowIndex].Cells[3].Text;
            decimal totalpay = Convert.ToDecimal(GridView1.Rows[e.RowIndex].Cells[5].Text);
            orderlist.removeFr(id);
            orderlist.insertTo(id2, name, adress, phone, totalpay, "是", tb.Text, Convert.ToInt32(ddl.SelectedItem.Text));
        }


        GridView1.DataSource = orderlist.returnOrderList1();
        GridView1.DataBind();
    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        OrderList orderlists = new OrderList();
        GridView1.DataSource = orderlists.returnOrderList1();
        GridView1.DataBind();
    }
    protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
    {

    }
}